#include <iostream>
#include <algorithm>
struct Act{
int s, f;
Act(){}
Act(int _s, int _f): s(_s), f(_f) {}
~Act(){}
void set(int _s, int _f){
this->s=_s;
this->f=_f;
}
};
bool ActCmp(Act act1, Act act2){
return act1.f<act2.f;
}
struct Acts{
Act* arr;
int size, cap=0;
Acts(int _size): size(_size) {
this->arr=new Act[this->size];
}
void insert(int _s, int _f){
if(cap==size){
std::cout<<"Acts Full"<<std::endl;
exit(1);
}
arr[cap++].set(_s, _f);
}
void sort(void){
std::sort(arr, arr+size, ActCmp);
}
int s(int ind){
return this->arr[ind].s;
}
int f(int ind){
return this->arr[ind].f;
}
};
struct Array{
int* arr;
int sz, cap=0;
Array(int _sz): sz(_sz) {
arr=new int[sz];
}
void insert(int ind){
this->arr[this->cap++]=ind;
}
void print(void){
for(int i=0; i<this->cap; ++i) std::cout<<arr[i]<<' ';
std::cout<<std::endl;
}
};
void RecursiveActivitySelector(Acts acts, int k, int n, Array& index){
int m=k+1;
while(m<=n && acts.s(m)<acts.f(k)) m=m+1;
if(m<=n) {
index.insert(m+1);
RecursiveActivitySelector(acts, m, n, index);
return;
}
else return;
}
int main(void){
Acts acts(11);
Array index(11);
int s[11]={1, 3, 0, 5, 3, 5, 6, 8, 8, 2, 12};
int f[11]={4, 5, 6, 7, 9, 9, 10, 11, 12, 14, 16};
for(int i=0; i<11; ++i) acts.insert(s[i], f[i]);
acts.sort();
RecursiveActivitySelector(acts, -1, 11, index);
index.print();
return 0;
}